package com.zwp.base.binding

import android.widget.Switch
import androidx.databinding.BindingAdapter

@BindingAdapter(value = ["switchState"])
fun setSwitchState(switch: Switch, state: Boolean) {
    switch.isChecked = state
}

@BindingAdapter(value = ["onCheckedChangeCommand"])
fun onCheckedChangeCommand(switch: Switch, bindingCommand: BindingCommand<Boolean>?) {
    switch.setOnCheckedChangeListener { compoundButton, b ->
        bindingCommand?.execute(b)
    }
}